package it.gat.client.view;

import javax.swing.table.AbstractTableModel;

public class TableModel extends AbstractTableModel {
	
	private Object[][] data;
	private String[] columnNames;
	
	public TableModel(Object[][] data,String[] columnNames)
	{
		this.data=data;
		this.columnNames=columnNames;
	}
	
	public int getColumnCount() {
        return columnNames.length;
    }

    public int getRowCount() {
        return data.length;
    }

    public String getColumnName(int col) {
        return columnNames[col];
    }

    public Object getValueAt(int row, int col) {
        return data[row][col];
    }

    public Class getColumnClass(int c) {
        return getValueAt(0, c).getClass();
    }
    
    public boolean isCellEditable(int row, int col) {
        return (col == 1); 
    }
    
    public void setValueAt(Object value, int row, int col) {
        data[row][col] = value;
        fireTableCellUpdated(row, col);
    }

}
